package AcWing.每日一题2025;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ZhuYi
 * @create 2025/3/5 10:12
 * 枚举
 */
public class 哞叫时间_6123 {

    static boolean[][] res = new boolean[26][26];
    static int[][] cnt = new int[26][26];
    static int n;
    static int f;
    static int N = 20010;
    static char[] s = new char[N];


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] split = br.readLine().split(" ");
        n = Integer.parseInt(split[0]);
        f = Integer.parseInt(split[1]);
        s = br.readLine().toCharArray();
        for (int i = 0; i < s.length; i++) {
            s[i] -= 'a';
        }

        //统计原串的符合标准的三个字符个数
        update(0, n - 1, 1);
        //修改字符，再次判断
        for (int i = 0; i < n; i++) {
            char t = s[i];
            //防止重复统计
            update(i - 2, i + 2, -1);
            for (int j = 0; j < 26; j++) {
                if (j != t) {
                    s[i] = (char) j;
                    update(i - 2, i + 2, 1);
                    //恢复，便于换下个字母时统计
                    update(i - 2, i + 2, -1);
                }
            }
            s[i] = t;
            update(i - 2, i + 2, 1);
        }

        int result = 0;
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < 26; j++) {
                if (res[i][j]) {
                    result++;
                }
            }
        }
        System.out.println(result);
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < 26; j++) {
                if (res[i][j] == true) {
                    char a = (char) ('a' + i);
                    char b = (char) ('a' + j);
                    System.out.println("" + a + b + b);
                }
            }
        }
    }

    static void update(int l, int r, int v) {
        l = Math.max(0, l);
        r = Math.min(n - 1, r);
        for (int i = l; i + 2 <= r; i++) {
            char a = s[i], b = s[i + 1], c = s[i + 2];
            if (a != b && b == c) {
                cnt[a][b] += v;
                if (cnt[a][b] >= f) res[a][b] = true;
            }
        }
    }
}
